﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Demo.TspDemo.ServiceSSVG;
using Net_Trading;

namespace Demo.TspDemo
{
    public partial class fen_vehicule : Form
    {
        public fen_vehicule()
        {
            InitializeComponent();
        }

        private void fen_vehicule_Load(object sender, EventArgs e)
        {
            Singleton s = Singleton.Instance;
            panel_ajout.Visible = false;
            panel_modif.Visible = false;
            if (!s.Modif)
            {
                panel_ajout.Visible = true;
            }
            else
            {

                panel_modif.Visible = true;
                using (Service1 serv = new Service1())
                {

                    var emp = serv.ConsulterChauffeur(s.Id);
                   
                    textEdit8.Text = emp.Nom;
                    textEdit7.Text = emp.Prenom;
               
                }
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (textEdit2.Text == "" || textEdit1.Text == "" )
            {
                MessageBox.Show("Veillez remplir les champs obligatoires!");
            }
            else
            {
                Service1 serv = new Service1();
                if (serv.AjouterVehicule(textEdit2.Text, textEdit1.Text))
                {
                    MessageBox.Show("Enregistrement Effectué avec Succès !");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Enregistrement Impossible !");
                }
            }
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void simpleButton5_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Butt_Modif_Veh_Click(object sender, EventArgs e)
        {
            Singleton s = Singleton.Instance;
            Service1 serv = new Service1();
            if (textEdit1.Text == "" || textEdit2.Text == "")
            {
                MessageBox.Show("Veillez remplir les champs obligatoires!");
            }
            else
            {
                if (serv.ModifierVehicule(textEdit1.Text,textEdit2.Text,s.Id))
                {
                    MessageBox.Show("Modification Effectuée avec Succès !");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Modification Impossible !");
                }
            }
        }

       
    }
}
